package com.zian.utils;


import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class ServerUtils {

    // 获取IP
    public static String getIpAddress() {
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            return inetAddress.getHostAddress();
        } catch (UnknownHostException e) {
            return "127.0.0.1";
        }

    }

    // 获取端口
    public static int getPort(HttpServletRequest request) {
        return request.getServerPort();
    }

}
